export default [
  {
    url: '/api/auth/login',
    method: 'post',
    response: ({ body }) => {
      if (['admin', 'user'].includes(body.name)) {
        return {
          code: 200,
          data: {
            token: `${body.name}-token123`,
          },
          success: true,
        }
      } else {
        return {
          code: 200,
          message: '没有此用户',
          success: false,
        }
      }
    },
  },
  {
    url: '/api/auth/getUserInfo',
    method: 'get',
    response: ({ headers }) => {
      const role = headers.token.split('-')[0]
      switch (role) {
        case 'admin':
          return {
            code: 200,
            data: {
              role: 'admin',
              userInfo: {
                name: '管理员',
              },
            },
            success: true,
          }
          break
        case 'user':
          return {
            code: 200,
            data: {
              role: 'user',
              userInfo: {
                name: '普通用户',
              },
            },
            success: true,
          }
          break
        default:
          return {
            code: 200,
            message: '没有此用户',
            success: false,
          }
      }
    },
  },
]
